<template>
  <div>
    <van-popup
      v-model="show2"
      position="top"
      duration="0"
      :style="{ height: '100%' }"
    >
      <van-nav-bar
        fixed
        border
        :title="config.label"
        left-text="返回33"
        :left-arrow="true"
        @click-left="show2 = false"
      >
        <template #title>
          <div @click="onhelp">
            <span>
              {{ config.label }}
            </span>
            <van-icon name="question-o" size="18" />
          </div>
        </template>
      </van-nav-bar>
      <div>1&nbsp;</div>
      <div>2&nbsp;</div>
      <div>&nbsp;</div>

      <div v-for="o2mfld in o2mConfig" :key="o2mfld.name">
        <ViewCell :data="data" :config="o2mfld" />
      </div>
    </van-popup>
  </div>
</template>

<script>
// import ViewCell from './ViewCell'

export default {
  name: 'ViewPopup',

  // components: { ViewCell },

  props: {
    show: { type: Boolean, default: false },
    config: {
      type: Object,
      default: () => {
        return {}
      }
    },
    data: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },

  data() {
    return {
      showData: {}
    }
  },
  computed: {
    //

    o2mConfig() {
      // console.log('getO2mConfig,', this.config)
      const config = this.config
      const fields = (config.propForView || {}).fields || {}
      return Object.keys(fields).map(item => {
        const meta = (config.fields || {})[item] || {}
        const me = fields[item] || {}
        const label = me.label !== undefined ? me.label : meta.string
        return { name: item, ...meta, ...me, label }
      })
    },
    show2: {
      get() {
        return this.show
      },

      set(val) {
        this.$emit('showclose')
      }
    }
  },

  async created() {},

  mounted() {
    // console.log('ViewPopup, config,', this.config.name, this.config)
    // console.log('ViewPopup, data,', this.data)
  },

  methods: {
    onhelp() {
      console.log('onhelp')
    }
  }
}
</script>

<style type="text/css"></style>
